// 第一题
// 数组、字符串的includes方法和indexof方法区别

// 1、NaN includes能匹配数组中的NaN,indexof不能匹配到
let ar1 = [NaN, 1, '3'];
console.log('ar1:', ar1.includes(NaN))// true
console.log('ar1:', ar1.indexOf(NaN))// -1
// undefined includes能匹配到稀疏数组中的undefined，indexof不行
let ar2 = [];
ar2[2] = 1;
console.log('ar2:', ar2.includes(undefined));// true
console.log('ar2:', ar2.indexOf(undefined));// -1

// 2字符串和数组中的indexof方法比较
// 不同点1:字符串会进行类型转换
let arr = ['1', '2', '3', '4'];
console.log('数组中：', arr.includes(1)) // false
console.log('数组中：', arr.includes('1')) // true

let str = '12345';
console.log('str:', str.includes(1)); // true
console.log('str:', str.indexOf(1)); // 0
console.log('str:', str.indexOf('1')); // 0


